package net.factoryOpen.quickfactory.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import net.factoryOpen.quickfactory.system.domain.SysBillFrozen;
import net.factoryOpen.quickfactory.system.service.ISysBillFrozenService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 单对象冻结Controller
 *
 * @author factoryOpen
 * @date 2024-06-18
 */
@RestController
@RequestMapping("/system/billFrozen")
public class SysBillFrozenController extends BaseController
{
    @Autowired
    private ISysBillFrozenService sysBillFrozenService;

    /**
     * 查询单对象冻结列表
     */
    //@PreAuthorize("@ss.hasPermi('system:billFrozen:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBillFrozen sysBillFrozen)
    {
        startPage();
        List<SysBillFrozen> list = sysBillFrozenService.selectSysBillFrozenList(sysBillFrozen);
        return getDataTable(list);
    }

    /**
     * 导出单对象冻结列表
     */
    //@PreAuthorize("@ss.hasPermi('system:billFrozen:export')")
    @Log(title = "单对象冻结", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBillFrozen sysBillFrozen)
    {
        List<SysBillFrozen> list = sysBillFrozenService.selectSysBillFrozenList(sysBillFrozen);
        ExcelUtil<SysBillFrozen> util = new ExcelUtil<SysBillFrozen>(SysBillFrozen.class);
        util.exportExcel(response, list, "单对象冻结数据");
    }

    /**
     * 获取单对象冻结详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:billFrozen:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysBillFrozenService.selectSysBillFrozenById(id));
    }

    /**
     * 新增单对象冻结
     */
    //@PreAuthorize("@ss.hasPermi('system:billFrozen:add')")
    @Log(title = "单对象冻结", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBillFrozen sysBillFrozen)
    {
        return toAjax(sysBillFrozenService.insertSysBillFrozen(sysBillFrozen));
    }

    /**
     * 修改单对象冻结
     */
    //@PreAuthorize("@ss.hasPermi('system:billFrozen:edit')")
    @Log(title = "单对象冻结", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBillFrozen sysBillFrozen)
    {
        return toAjax(sysBillFrozenService.updateSysBillFrozen(sysBillFrozen));
    }

    /**
     * 删除单对象冻结
     */
    //@PreAuthorize("@ss.hasPermi('system:billFrozen:remove')")
    @Log(title = "单对象冻结", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysBillFrozenService.deleteSysBillFrozenByIds(ids));
    }


}
